#include <iostream>
using std::cout;
using std::endl;

class Point{
public:
    static Point * getInstance(){
        if(_pInstance == nullptr){
            _pInstance = new Point;
        }
        return _pInstance;
    }

    void init(int x,int y){
        _ix = x;
        _iy = y;
    }
    void print() const{
        cout << "(" << _ix << "," 
            << _iy << ")" << endl;
    }
    static void destroy(){
        if(_pInstance){
            delete _pInstance;
            _pInstance = nullptr;
        }
    }
private:
    Point() = default;
    ~Point(){ cout << "~Point()" << endl; }
private:
    int _ix;
    int _iy;
    static Point* _pInstance;
};
Point* Point::_pInstance = nullptr;

void test0(){
    /* Point * p = Point::getInstance(); */
    /* p->init(1,2); */
    /* p->print(); */
    Point::getInstance()->init(100,200);
    Point::getInstance()->print();
    Point::destroy();
}

int main(void){
    test0();
    return 0;
}
